<template>
  <div class="pass">
    <!-- 通行证管理 -->
    <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>住户申请信息</el-breadcrumb-item>
    </el-breadcrumb>
  </div>

  <el-card>
    <div class="height">
      <el-form :label-position="labelPosition" label-width="80px">
        <el-form-item label="姓名">
          <el-input v-model="formInline.uname"></el-input>
        </el-form-item>

        <el-form-item label="身份证号">
          <el-input v-model="formInline.idCard"></el-input>
        </el-form-item>

        <el-form-item label="年龄">
          <el-input v-model="formInline.age"></el-input>
        </el-form-item>

        <el-form-item label="性别">
          <el-select v-model="formInline.gender" placeholder="请选择">
            <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="地址">
          <el-input v-model="formInline.address"></el-input>
        </el-form-item>

        <el-form-item label="电话号码">
          <el-input v-model="formInline.phone"></el-input>
        </el-form-item>

        <el-form-item label="备注">
          <el-input v-model="formInline.note"></el-input>
        </el-form-item>
        <div class="button">
          <el-form-item>
            <el-button color="red" @click="submitForm">保存</el-button>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="back">返回</el-button>
          </el-form-item>
        </div>
      </el-form>
    </div>
  </el-card>
</template>

    <script>
import { addBaseApi } from "../api/index1.js";
import { ElMessage } from "element-plus";
export default {
  data() {
    return {
      labelPosition: "left",
      options: [
        {
          value: "男",
          label: "男",
        },
        {
          value: "女",
          label: "女",
        },
      ],
      formInline: {
        address: "",
        age: "",
        gender: "",
        idCard: "",
        note: "",
        phone: "",
        uname: "",
      },
      // ruleForm: {
      //     user: '',
      //     region: '',

      //     desc: ''
      // },
      // rules: {
      //     desc: [
      //         { required: true, message: '请填写活动形式', trigger: 'blur' }
      //     ]
      // }
    };
  },
  methods: {
    back() {
      this.$router.push({
        path: "../views/userManage", //要跳转的页面的路由
      });
    },
    //查询
    onSubmit() {
      console.log("submit!");
    },
    submitForm() {
      addBaseApi(this.formInline).then((res) => {
        console.log(res);
        this.formData = {};
        // 2.提示用户添加成功
        if (res.code == 20000) {
          ElMessage({
            message: "添加成功",
            type: "success",
          });
        }
        //   this.$router.back()
        this.$router.push("../views/userManage");
        // this.passList = res.data.data;

      });
    },
    //提交校验
    // submitForm(formName) {
    //     this.$refs[formName].validate((valid) => {
    //         if (valid) {
    //             alert('submit!');
    //         } else {
    //             console.log('error submit!!');
    //             return false;
    //         }

    //         if (res.code == 20000) {
    //             ElMessage({
    //                 message: "保存成功",
    //                 type: "success",
    //             });
    //         }
    //     }
    //     );
    // },
    // resetForm(formName) {
    //     this.$refs[formName].resetFields();
    // }
  },
};
</script>

    <style lang="less" scoped>
.el-form {
  width: 800px;
}

.notice {
  margin-top: 10px;
  font-weight: bold;
}

.height {
  margin-top: 20px;
}

.height {
  line-height: 10px;
}

.el-input {
  width: 220px;
}

.el-card {
  margin-top: 10px;
  height: 100%;
}

.button {
  display: flex;
}
</style>
